//
//  main.m
//  oc_类的创建2
//
//  Created by blue on 16/4/6.
//  Copyright (c) 2016年 zzn. All rights reserved.
//

#import <Foundation/Foundation.h>
/*定义类：
   1 实例变量:
   NSString *_name,
   double _price,
   NSString *_author
  类对象，是指针类型*
  2 方法的定义：一般给每个实例变量
   定义两个方法：
   setter方法(给实例变量赋值)命名规则：
     set＋实例变量名，注意首字母大写
   getter方法（得到实例变量值）命名规则：
      实例变量名
 */
@interface Book : NSObject
{
    NSString *_name;
    NSString *_author;
    double _price;
}
-(void)setName:(NSString *)name;
//将变量name给实例变量_name赋值
-(void)setAuthor:(NSString *)author;
-(void)setPrice:(double)price;
//同时给三个实例变量赋值
//方法名 setName:andAuthor:andPrice
-(void)setName:(NSString *)name
     andAuthor:(NSString *)author
      andPrice:(double)price;
//同时给name，author两个实例变量赋值
//方法名： setName:andAuthor
-(void)setName:(NSString *)name
     andAuthor:(NSString *)author;

-(void)setAuthor:(NSString *)author
        andPrice:(double)price;


-(NSString *)name;
-(NSString *)author;
-(double)price;
@end


@implementation Book

-(void)setName:(NSString *)name;
{
    _name = name;
}
-(void)setAuthor:(NSString *)author{
    _author = author;
}
-(void)setPrice:(double)price{
    _price = price;
}

-(void)setName:(NSString *)name andAuthor:(NSString *)author{
    _name = name;
    _author = author;
}

-(void)setName:(NSString *)name andAuthor:(NSString *)author andPrice:(double)price
{
    _name = name;
    _author = author;
    _price = price;
}

-(void)setAuthor:(NSString *)author
        andPrice:(double)price
{
    _author = author;
    _price = price;
}
-(NSString *)name{
    return _name;
}
-(NSString *)author{
    return _author;
}
-(double)price{
    return _price;
}

@end


int main(int argc, const char * argv[]) {
    @autoreleasepool {
       //方法的调用，－方法，实例调用
        
        NSLog(@"书名\t\t作者\t\t价格");
        Book *b1=[[Book alloc]init];
        [b1 setAuthor:@"liyang" andPrice:35];
        [b1 setName:@"实用英语"];
         NSLog(@"%@\t%@\t%g",[b1 name],
               [b1 author],[b1 price]);
    
        Book *b2=[[Book alloc]init];
        [b2 setName:@"oc程序设计"
          andAuthor:@"zhouyu"
           andPrice:56];
      
     
    
        
      
    }
    
    return 0;
}
